package com.cn.zengzeng.spbzengzeng.vo;

import com.cn.zengzeng.spbzengzeng.enums.CodeAndMsgEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 响应返回
 * @Author: zhangzengzeng
 * @Date: 2021/6/4 14:49
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ActionResult {
    /**
     * 响应码
     */
    private String code ;
    /**
     * 响应信息
     */
    private String message ;
    /**
     * 相关数据
     */
    private Object data ;

    public static ActionResult getSuccessResult(String code){
        CodeAndMsgEnum byCode = CodeAndMsgEnum.getByCode(code);
        return new ActionResult(byCode.getCode(),byCode.getDescription(),null);
    }
    public static ActionResult getSuccessResult(String code,Object obj){
        CodeAndMsgEnum byCode = CodeAndMsgEnum.getByCode(code);
        return new ActionResult(byCode.getCode(),byCode.getDescription(),obj);
    }
}
